<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
        .box {
            position: absolute;
            left: 0px;
            top: 0px;
        }
    </style>
</head>

<body>
    <div class="box">x:0px;y:0px</div>
    <script>
        var boxEle = document.querySelector(".box");
        document.onmousemove = function(event) {
            var e = event || window.event;
            var x = e.clientX;
            var y = e.clientY;
            console.log(x);
            boxEle.style.left = x + "px";
            boxEle.style.top = y + "px";
            boxEle.innerHTML = `x:${x};y:${y}`;
        };
    </script>
</body>

</html>